#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=3e5+1000;
typedef long long LL;
const LL base=131;
const LL mod=998244353;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL h[maxn],p1[maxn],p2[maxn];
LL dp[maxn];
char str[maxn];
LL n;
LL cal(LL p[],LL l,LL r){
   return (p[r]%mod-p[l-1]*h[r-l+1]%mod+mod)%mod;
}
bool check(LL mid,LL r){
   LL temp1=cal(p1,mid,r);
   LL len=r-mid+1;
   LL l=r-len+1;
   LL temp2=cal(p1,l,mid);
   cout<<"temp1="<<temp1<<" "<<"temp2="<<temp2<<"\n";
   if(len==1) return false;
   if(temp1==temp2) return true;
   else return false;
}
int main(void){
   ///cin.tie(0);std::ios::sync_with_stdio(false);
   cin>>n;
   cin>>(str+1);
   h[0]=1;
   for(LL i=1;i<maxn;i++) h[i]=h[i-1]*base%mod;
   for(LL i=1;i<=n;i++){
       p1[i]=(p1[i-1]*base%mod+str[i]-'a'+1)%mod;
       p2[i]=(p2[i-1]*base%mod+str[n-i+1]-'a'+1)%mod;
   }
   for(LL i=1;i<=n;i++){
       cout<<p1[i]<<"     ";
   }
   cout<<"\n";
   for(LL i=1;i<=n;i++){
       cout<<p2[i]<<"     ";
   }
   cout<<"\n";
   cout<<cal(p1,3,5)<<"\n";
   dp[0]=0;
   dp[1]=0;
   for(LL i=2;i<=n;i++){
       LL l=0;LL r=i;
       while(l<r){
          LL mid=(l+r+1)>>1;
          if(check(mid,i)==true) l=mid;
          else r=mid-1;
       }
       cout<<"i="<<i<<" "<<"l="<<l<<"\n";
       dp[i]=dp[i-1];
       if(l!=0) dp[i]+=(l-1)+1;
   }
   for(LL i=1;i<=n;i++){
     cout<<dp[i]<<" ";
   }
   cout<<"\n";
   cout<<dp[n]<<"\n";
   return 0;
}
